/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import Data.Phong;
import Data.ToaTau;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author bienphongvnn
 */
public class PhongModel {
    public static ArrayList<Phong> ListPhong(int loaitoa) {	
        ArrayList<Phong> ds = new ArrayList<Phong>();
        Connection con = ConnectionProvider.Connect();
	try {
            String sql = String.format("select distinct p.MaPhong from phong p, toatau tt where p.MaToa = tt.MaToa and tt.LoaiToa = '%d'", loaitoa);
            Statement statement	= con.createStatement();	
            ResultSet rs = statement.executeQuery(sql);
            while(rs.next()){	
                Phong p = new Phong();
                p.MaPhong = rs.getString("MaPhong");
                ds.add(p);
                } 
            con.close();
        }
        catch(Exception ex){
            System.out.println(ex.getMessage());	
        }
        finally
        {
           
        }
        return	ds;	
    }
}
